<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
 *奖励
 *@author zhu
 *@time 20150801
 */
class User_reward_model extends CI_Model {
	function __construct(){
        parent::__construct();
    }
    
    function add($data = array()){
		$this->db->insert('rsh_user_reward', $data);
		return $this->db->affected_rows();
    }
    
    
    function get_one($where = array(),$select='*'){
		$this->db->select($select);
		if($where){
			$this->db->where($where);
		}
		$this->db->limit(1);
		$query = $this->db->get('rsh_user_reward');
		return $query->row_array();
    }
	
    /*
     *检查用户是否已经领过红包
     *@param array $where
     *@time 20150802
     */
    function checkuser($where=array(),$select='*'){
	$this->db->select($select);
	if($where){
		$this->db->where($where);
	}
	$this->db->limit(1);
	$query = $this->db->get('rsh_user_reward');
	return $query->row_array();
    }	

    /*
     *批量数据脚本
     *@time  20150803
     *
     */
    function jiaoben_test(){
	//5元红包领取
	/*for($i=0;$i<10;$i++){
		$jb_sql="INSERT INTO rsh_account_log(user_id,ftype,total,money,use_money,no_use_money,collection,to_user,remark,add_time,addip,op)
SELECT user_id,ftype,total,money,use_money,no_use_money,collection,to_user,remark,add_time,addip,op FROM rsh_account_log_{$i}
WHERE money=5";
	//$query=$this->db->query($jb_sql);
	}*/
	
	//8月微信分享奖励
	$userarr=array(10936,10934,10930,10940,10937,10938,10942,10941,10946,10945,10947,10949,10948,10965,10964,10962,10951,10952,10968,10967,10963,10975,10976,10973,10972,10977,10979,10974,10980,10969,10978);

	foreach ($userarr as $value) {
		$Cdata['user_id']=$value;
		$Cdata['total']=18;
		$Cdata['ftype']=11;
		$Cdata['money']=18;
		$Cdata['use_money']=18;
		$Cdata['no_use_money']=0.00;
		$Cdata['collection']=0;
		$Cdata['to_user']=0;
		$Cdata['remark']="8月微信分享18元奖励";
		$Cdata['add_time']=1439796600;
		$Cdata['addip']="127.0.0.1";
		$mode=substr(strval($value),-1,1);
		$this->db->insert('rsh_account_log_'.$mode,$Cdata);
	}

	//投标奖励20150805记录
	/*
	$uid=10904;
	$Cdata['user_id']=$uid;
	$Cdata['total']=102041.12;
	$Cdata['ftype']=11;
	$Cdata['money']=552.91;
	$Cdata['use_money']=737.21;
	$Cdata['no_use_money']=0.00;
	$Cdata['collection']=93303.91;
	$Cdata['to_user']=0;
	$Cdata['remark']="7月月标第三重奖返现";
	$Cdata['add_time']=1438768800;
	$Cdata['addip']="127.0.0.1";
	$mode=substr(strval($uid),-1,1);
	$this->db->insert('rsh_account_log_'.$mode,$Cdata);
	echo 'success'.$uid;
	*/
	//var_dump($Adata);
	//$tb_sql="INSERT INTO rsh_account_log_5(user_id,ftype,total,money,use_money,no_use_money,collection,to_user,remark,add_time,addip,op)VALUES(10745,11,38512.5,60.2,60.25,)";	
	
    }

}


